<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('红黑榜列表')" />
</head>
<body class="gray-bg">
	<div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="role-form">
					<div class="select-list">
						<ul>
							<li>
								被检查单位：<input type="text" name="enterpriseName"/>
							</li>
							<li>
								招牌名称：<input type="text" name="shopSign"/>
							</li>
							<li>
								类型：<select name="listType" th:with="type=${@dict.getType('sys_normal_disable')}">
									<option th:value="3">所有</option>
									<option th:value="0">黑榜</option>
									<option th:value="1">红榜</option>
								</select>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							    <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
		
			<div class="btn-group-sm" id="toolbar" role="group">
				<a class="btn btn-success" onclick="add()" >
	                <i class="fa fa-plus"></i> 新增
	            </a>
	            <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="redBlack:update">
		            <i class="fa fa-edit"></i> 修改
		        </a>
				<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="redBlack:delete">
		            <i class="fa fa-remove"></i> 删除
		        </a>
	        </div>
	        
	        <div class="col-sm-12 select-table table-striped">
			    <table id="bootstrap-table"></table>
			</div>
		</div>
	</div>
	<th:block th:include="include :: footer" />
	<script th:inline="javascript">
		var prefix = ctx + "redBlack";
		

		$(function() {
		    var options = {
		        url: prefix + "/list",
		        updateUrl: prefix + "/update/{id}",
		        removeUrl: prefix + "/delete",
		        sortName: "listId",
		        sortOrder: "desc",
		        modalName: "紅黑榜",
		        columns: [{
		            checkbox: true
		        },
		        {
		            field: 'listId',
		            title: '红黑榜id',
		            visible: false
		        },
		        {
		            field: 'enterpriseName',
		            title: '被检查单位'
		        },
		        {
		            field: 'shopSign',
		            title: '招牌名称',
		            sortable: true
		        },
		        {
		            field: 'address',
		            title: '经营地址',
		            sortable: true
		        },
		        {
		            field: 'evalTime',
		            title: '评比时间',
		            sortable: true,
		            formatter: function (value, row, index) {
		                return changeDateFormat(row.evalTime);
		            }
		        },
		        {
		            field: 'listType',
		            title: '类型',
		            sortable: true,
		            formatter: function (value, row, index) {
		        		if(value=="0"){
		        			return "黑榜";
		        		}else if(value=="1"){
		        			return "红榜"
		        		}
		        	}
		        }]
		    };
		    $.table.init(options);
		});
		
		function add(){
			 var url = 'redBlack/add';
			 $.modal.open("紅黑榜新增", url);
		}
		function edit(){
			var url = 'redBlack/update';
			 $.modal.open("紅黑榜修改", url);
		}
		
		function changeDateFormat(cellval) {
			if (cellval != null){
			    var date = new Date(cellval);
			    var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
			    var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
			    return date.getFullYear() + "-" + month + "-" + currentDate;
			    }
			}
		

	</script>
</body>
</html>